#include "syscall.h"
//cp command, makes a copy of an existing file
int main(int argc, char **argv){

    //invalid argument structure
    if (argc != 3) {
        Exit(1);
    }

    OpenFileId fileToCopy = Open(argv[1]);

    //failed to open file
    if (fileToCopy == -1) {
        Exit(1);
    }


    Create(argv[2]);
    OpenFileId fileToWriteTo = Open(argv[2]);

    if (fileToWriteTo == -1) {
        Exit(1);
    }

    char buffer[10];
    int bytesRead;

    do {
        bytesRead = Read(buffer, 10, fileToCopy);
        Write(buffer, bytesRead, fileToWriteTo);

    } while (bytesRead != 0);



    Close(fileToCopy);
    Close(fileToWriteTo); 
    
    Exit(0);
}
